<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        class Common {
            sum() {
                console.log('sum....')
                return this.data.reduce((t, item) => t + item.price, 0)
            }
        }
        class Controller extends Common {
            constructor() {
                super()
                // console.log('父类的构造函数........')
            }
        }
        class Lesson extends Controller {
            constructor(data) {
                // super.方法 如果super后面没有调方法 会自动掉父类的构造函数
                super();
                this.data = data;
            }
            info() {
                // 返回总价
                return {
                    totalPrice: super.sum(),
                    data: this.data
                }
            }
        }
        let data = [
            { name: 'js', price: 58 },
            { name: 'css', price: 65 },
            { name: 'node', price: 120 }
        ]
        
        let les = new Lesson(data);
        console.log(les.info())

        
    </script>
</body>

</html>